# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=librevenge
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.0.4
pkgrel=2
pkgdesc="Library for REVerses ENGineered formats filters (mingw-w64)"
arch=('any')
url="https://sourceforge.net/p/libwpd/librevenge/"
license=("MPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-doxygen"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-doxygen")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-boost"
         "${MINGW_PACKAGE_PREFIX}-zlib")
checkdepends=("${MINGW_PACKAGE_PREFIX}-cppunit")
options=(staticlibs strip)
source=("https://sourceforge.net/projects/libwpd/files/librevenge/${_realname}-${pkgver}/${_realname}-${pkgver}.tar.xz")
sha256sums=('933f0729f04267cc354b9a02bc3e9afefa5512a3bdd0b45f159ee14a3e3347b2')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
}

build() {
  export lt_cv_deplibs_check_method='pass_all'
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  cp -r ${srcdir}/${_realname}-${pkgver} "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --enable-static \
    --with-docs=yes

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING.LGPL" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING.LGPL"
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING.MPL" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING.MPL"
}
